package com.wn.controller;

import com.wn.entity.Emp;
import com.wn.entity.idCard;
import com.wn.idCard.IDCardUtil;
import com.wn.service.SampleService;
import com.wn.service.impl.SampleServiceImpl;
import com.wn.utils.DownloadImage;
import com.wn.utils.Rsp;
import com.wn.utils.Station;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RequestMapping("idCard")
@RestController
public class idcardController {

    @Autowired
    private SampleService sampleService;



    @PostMapping("card")
    public Rsp card(@RequestBody idCard f){
        String filename =null ;
        try {
            System.out.println(f.getIdCardText());
            filename = DownloadImage.abc(f.getIdCardText());
        }catch (Exception e){
            e.printStackTrace();
        }
        filename = "D:\\image\\"+filename;
        System.out.println(filename);

        return Rsp.success(sampleService.idcard(filename));
    }


    @PostMapping("/upIdImg")
    public Rsp upIdImg(@RequestParam("image") MultipartFile image) throws Exception {
        System.out.println("-----------------------");
        byte[] bytes = image.getBytes();
        String idMsg = IDCardUtil.getIdMsg(bytes);
        log.debug(idMsg);
        System.out.println(idMsg);
        return Rsp.success(idMsg);
    }



}
